unit TJLinux.HttpWs;

interface
uses
  qjson,
  qstring,
  TJ.FMX.Comm,
  TJ.FMX.ControlComm,
  HttpWsHandle,
  TJ.FMX.HttpPostServer,
  System.SysUtils, System.Classes;

type
  THttpWs = class(THxPostServer)
  private
     function AysnToDev(Path: string; AJson: TQJson;Server: IHttpPostServer): string;
  public
     constructor Create(Port: Integer; Log: TOnLogEvent;ServerType:Integer=1);overload;
     destructor Destroy; override;
  end;


implementation

{ THttpProxy }

constructor THttpWs.Create(Port: Integer; Log: TOnLogEvent;ServerType:Integer=1);
begin
  inherited Create(Port,'/ws',Log,ServerType);
  AddPath('/AysnToDev');
  SetLog(Log);
  //HttpServer.Post('/app/:url',OperPost);
  //HttpServer.Post('/ws/AysnToDev',OperPost);
  InitAppManageFun(nil);
  OnRetHandle :=  AysnToDev;
end;

destructor THttpWs.Destroy;
begin
  inherited;
//  FreeHClient;
  FreeAndNil(LocalAppManageFun);
end;

function THttpWs.AysnToDev(Path: string; AJson: TQJson;
  Server: IHttpPostServer): string;
var
  CurPath   :   string;
  LvRetI    :   Integer;
begin
  LvRetI := ExecuteTwoRoutine(LocalAppManageFun,AJson.ValueByName('Fun',''),AJson);
  Result :=  ExitServerFun(AJson,LvRetI,Server.GetServerName);
end;



end.
